Add --single-dependency flag to jhack sync#242
Open
PietroPasotti wants to merge 1 commit intomainfrom
Open
Conversation
Adds a --single-dependency/-d flag that watches a local Python package directory and syncs changes into the charm's remote venv site-packages. The package name is auto-detected from pyproject.toml/setup.cfg (with PEP 503 normalization), falling back to the directory name. The remote Python version is discovered by listing the venv/lib/ directory on the target unit. Mutually exclusive with --venv, --remote-root, and --source. Closes #238
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--single-dependency/-dflag tojhack syncthat watches a local Python package directory and syncs changes into the charm's remote venvsite-packages.Closes #238
Usage
Instead of the current workaround:
What it does
Auto-detects the package name from
pyproject.toml([project].nameor[tool.poetry].name) orsetup.cfg([metadata].name), with PEP 503 normalization (lowercase, hyphens → underscores). Falls back to the directory name.Discovers the remote Python version by listing
<charm_venv>/lib/on the target unit viajuju ssh, so the user doesn't need to know or specifypython3.12vspython3.10etc.Constructs the full remote path automatically:
<venv>/lib/<python3.X>/site-packages/<pkg_name>/Validates flag incompatibilities — errors out early if combined with
--venv,--remote-root, or--source(which are all overridden by--single-dependency).Implementation details
_resolve_package_name()and_discover_remote_python_version()injhack/utils/sync.pylocal_root_overrideparameter onpush_to_remote_juju_unit()to correctly map files outside CWD to remote paths (fully backward-compatible — defaults toos.getcwd()when unset)